<?php
declare (strict_types=1);

namespace app\third\controller\api;

use app\BaseApiController;
use app\third\exceptions\ApiException;
use app\third\logic\MiniLogic;

/**
 * 微信小程序
 * Class Mini
 * @package app\third\controller\api
 */
class Mini extends BaseApiController
{
    /**
     * 上报code登陆
     * @return int[]
     * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
     */
    public function code()
    {
        $code = $this->request->post('code');
        if (!$code) {
            ApiException::throws(ApiException::$requireArgs);
        }
        //用户上报code
        MiniLogic::getInstance()->code($code);
        //检查
        return json([
            'token' => 112,
            'type' => 1
        ]);
    }

    /**
     * 绑定微信
     */
    public function bind()
    {
        //已登陆用户绑定

    }

    public function login()
    {

    }
}
